package b1.scenes.crime
{
	import b1.conifg.*;
	import b1.controls.basic.*;
	import b1.net.*;
	import b1.players.*;
	import b1.scenes.*;
	import b1.scenes.fight.*;
	import b1.scenes.home.*;
	import b1.utils.*;
	
	import flash.display.Sprite;
	import flash.filters.*;
	import flash.text.*;
	
	public class AnimalCrimeTip extends Sprite
	{
		private var playerInfo:PlayerInfo;
		private var tipOfEquip:Sprite;
		
		public function AnimalCrimeTip(playerId:int)
		{
			playerInfo = PlayerInfoHelper.getInstance().players[playerId];
			var roundRec:RoundRec;
			roundRec = new RoundRec(150, 160, 0.8, BFont.roundRecColor);
			addChild(roundRec);
			var helpText:TextField = new TextField();
			helpText.selectable = false;
        	helpText.width = roundRec.width;
        	helpText.autoSize = TextFieldAutoSize.CENTER;
			var helpTexFormat:TextFormat = new TextFormat("微软雅黑", 15, 0x000000, true);
			helpTexFormat.leftMargin = 5;
			helpTexFormat.rightMargin = 5;
			helpTexFormat.color = 0x008000;
			helpText.defaultTextFormat = helpTexFormat;
			helpText.text = "单击作案";
			helpText.y = 10;
			addChild(helpText);
			
			var gap:int = 10;
			//名字
			var nameText:TextField = new TextField();
			nameText.selectable = false;
        	nameText.width = roundRec.width;
        	nameText.autoSize = TextFieldAutoSize.LEFT;
			var nameTexFormat:TextFormat = new TextFormat("微软雅黑", 15, 0x000000, true);
			nameTexFormat.leftMargin = 5;
			nameTexFormat.rightMargin = 5;
			nameText.defaultTextFormat = nameTexFormat;
			nameText.y = 30;
			nameText.x = gap;
			nameText.text = playerInfo.name.substr(0,4);
			addChild(nameText);
			
			//居住的动物
			var liveAnimalNames:TextField = new TextField();
			liveAnimalNames.selectable = false;
			liveAnimalNames.autoSize = TextFieldAutoSize.LEFT;
			var liveAnimalNamesTextFormat:TextFormat = new TextFormat("微软雅黑", 13, 0x000000);
			liveAnimalNamesTextFormat.leftMargin = 5;
			liveAnimalNamesTextFormat.rightMargin = 5;
			liveAnimalNames.defaultTextFormat = liveAnimalNamesTextFormat;
			liveAnimalNames.appendText( "居住动物: " + playerInfo.liveAnimals.length);
			liveAnimalNames.y = 50;
			liveAnimalNames.x = gap;
			addChild(liveAnimalNames);
			var animalInfo:AnimalInfo = PlayerInfoHelper.getInstance().animals[playerInfo.liveAnimals[0]];
			var animalInfoText:TextField = new TextField();
			animalInfoText.selectable = false;
			animalInfoText.autoSize = TextFieldAutoSize.LEFT;
			animalInfoText.defaultTextFormat = liveAnimalNamesTextFormat;
			if (null != animalInfo)
			{
				if (playerInfo.type != 3 && playerInfo.type != 4)
				{
					animalInfoText.appendText("等级: " + animalInfo.level +"\n" + "血量: " + animalInfo.currentHealthPoint);
				}
				else
				{
					animalInfoText.appendText("血量: " + animalInfo.currentHealthPoint);
				}
				animalInfoText.appendText("\n体力: " + animalInfo.currentVitalityPoint + "\n" + "速度: " + animalInfo.speed + "\n");
				if (playerInfo.type == 3)
				{
					var equipText:TextField = new TextField();
					equipText.selectable = false;
        			equipText.autoSize = TextFieldAutoSize.LEFT;
					equipText.defaultTextFormat = liveAnimalNamesTextFormat;
					equipText.text = "掉落:";
					equipText.x = animalInfoText.x + 10;
					equipText.y = animalInfoText.y + animalInfoText.height + 65;
					addChild(equipText);
					//装备图标
					var startX:int = equipText.x + equipText.width + 8;
					var startY:int = equipText.y + 5;
					addEquipIcon((animalInfo as VirtualAnimalConfig).armsDropPossibility, startX, startY, true, false);
				}
			}
			animalInfoText.y = 70;
			animalInfoText.x = gap;
			addChild(animalInfoText);
		}
		
		//显示装备图标
		private function addEquipIcon(equips:Object, startX:int, startY:int, addMouseClickEventFlag:Boolean, equipDropFlag:Boolean = false):void
		{
			//装备图标
			var equipCount:int = 0;
			var disY:int = 0;
			for (var position:String in equips)
			{
				var equipConfig:EquipConfig = Config.objectConfigs[position];
				var EquipIcon:Class = ResourceHelper.getInstance().getClassByName(equipConfig.iconImage);
				var equipIcon:BasicButton = new BasicButton(EquipIcon, null, 15);
				equipIcon.width = 15;
				equipIcon.height = 15;
				equipIcon.x = startX + 22 * equipCount;
				equipIcon.y = startY + disY;
				addChild(equipIcon);
				var animalInfo:AnimalInfo = PlayerInfoHelper.getInstance().animals[playerInfo.ownAnimals[0]];
				equipCount++;
			}

		}
	}
}